package com.eeepay.eeepay_v2.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;

import com.eeepay.eeepay_v2.R;
import com.eeepay.eeepay_v2.model.OrderResult;
import com.eeepay.v2_library.adapter.ABBaseAdapter;
import com.eeepay.v2_library.adapter.ABViewHolder;

/**
 * Created by Ching on 2016/3/31.
 * 订单查询结果Adapter
 */
public class OrderResultAdapter extends ABBaseAdapter<OrderResult> {


    public OrderResultAdapter(Context context) {
        super(context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_query_order_result_list;
    }

    @Override
    public void convert(ABViewHolder holder, OrderResult model) {

        holder.setText(R.id.tv_order_item_name, model.getName());
        holder.setText(R.id.tv_order_item_product, model.getProduct());

        if ("待进件".equals(model.getStatus())) {
            SpannableString ss = new SpannableString(model.getStatus());
            ss.setSpan(new ForegroundColorSpan(Color.RED), 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            holder.setText(R.id.tv_order_item_status, ss);
        } else {
            holder.setText(R.id.tv_order_item_status, model.getStatus());
        }
    }

}
